package com.woniu.cms.goods.core.exception;

import com.woniu.common.api.Result;
import com.woniu.common.api.status.Impl.BusinessCode;
import org.springframework.validation.FieldError;
import org.springframework.web.bind.MethodArgumentNotValidException;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;

import javax.security.auth.login.LoginException;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;

/**
 * @author yellow Docter
 * @date 2022 -09-06
 * @desc
 *
 * 全局异常处理：
 *   @RestControllerAdvice + @ExceptionHandler 注解
 */
@RestControllerAdvice
public class GlobalException {

    /**
     * 处理login的异常
     * @param e
     * @return
     */
    @ExceptionHandler(BusinessException.class)
    public Result<String> handlerLoginException(Exception e){
        return Result.error(BusinessCode.MODIFY_SUCCESS);
    }

    /**
     * 处理其他的异常
     * @param e
     * @return
     */
    @ExceptionHandler(Exception.class)
    public Result<String> handlerMethodException(Exception e){
        return Result.error();
    }
}
